package com.ruoyi.web.controller.consultationreply;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.consultationreply.domain.Consultationreply;
import com.ruoyi.consultationreply.service.IConsultationreplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 资讯回复信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-07
 */
@RestController
@RequestMapping("/consultationreply/consultationreply")
public class ConsultationreplyController extends BaseController
{
    @Autowired
    private IConsultationreplyService consultationreplyService;

    /**
     * 查询资讯回复信息列表
     */
    @PreAuthorize("@ss.hasPermi('consultationreply:consultationreply:list')")
    @GetMapping("/list")
    public TableDataInfo list(Consultationreply consultationreply)
    {
        startPage();
        List<Consultationreply> list = consultationreplyService.selectConsultationreplyList(consultationreply);
        return getDataTable(list);
    }

    /**
     * 导出资讯回复信息列表
     */
    @PreAuthorize("@ss.hasPermi('consultationreply:consultationreply:export')")
    @Log(title = "资讯回复信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Consultationreply consultationreply)
    {
        List<Consultationreply> list = consultationreplyService.selectConsultationreplyList(consultationreply);
        ExcelUtil<Consultationreply> util = new ExcelUtil<Consultationreply>(Consultationreply.class);
        util.exportExcel(response, list, "资讯回复信息数据");
    }

    /**
     * 获取资讯回复信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('consultationreply:consultationreply:query')")
    @GetMapping(value = "/{replyId}")
    public AjaxResult getInfo(@PathVariable("replyId") Long replyId)
    {
        return AjaxResult.success(consultationreplyService.selectConsultationreplyByReplyId(replyId));
    }

    /**
     * 新增资讯回复信息
     */
    @PreAuthorize("@ss.hasPermi('consultationreply:consultationreply:add')")
    @Log(title = "资讯回复信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Consultationreply consultationreply)
    {
        return toAjax(consultationreplyService.insertConsultationreply(consultationreply));
    }

    /**
     * 修改资讯回复信息
     */
    @PreAuthorize("@ss.hasPermi('consultationreply:consultationreply:edit')")
    @Log(title = "资讯回复信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Consultationreply consultationreply)
    {
        return toAjax(consultationreplyService.updateConsultationreply(consultationreply));
    }

    /**
     * 删除资讯回复信息
     */
    @PreAuthorize("@ss.hasPermi('consultationreply:consultationreply:remove')")
    @Log(title = "资讯回复信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{replyIds}")
    public AjaxResult remove(@PathVariable Long[] replyIds)
    {
        return toAjax(consultationreplyService.deleteConsultationreplyByReplyIds(replyIds));
    }
}
